package com.usian.controller;

import com.usian.service.CartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class CartController {

    @Autowired
    private CartService cartService;


    @RequestMapping("getCartByUserId")
    public Map<String,Object> getCartByUserId(@RequestParam String userId){
         return cartService.getCartByUserId(userId);

    }

    @RequestMapping("addCartToRedis")
    public boolean addCartToRedis(@RequestParam String userId,
                                  @RequestBody Map<String,Object>cart){

        return cartService.addCartToRedis(userId,cart);
    }
}
